/*
 * @Author: 张升 1562821455@qq.com
 * @Date: 2023-07-15 19:28:12
 * @LastEditors: zhangsheng zhangsheng@zhixueyun.com
 * @LastEditTime: 2024-11-12 22:54:52
 * @FilePath: \react-demo\src\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import React from 'react';
import ReactDOM from 'react-dom/client';
import {initReactI18next} from 'react-i18next';
import i18n from 'i18next';
import translationEN from './locales/en/translation.json';
import translationZH from './locales/zh/translation.json';
import './index.css';
import App from './App';

const resources = {
  en: {
    translation: translationEN,
  },
  zh: {
    translation: translationZH,
  },
};
i18n.use(initReactI18next).init({
  resources,
  lng: 'zh', // 默认语言
  fallbackLng: 'en', // 备用语言
  interpolation: {
    escapeValue: false,
  },
});

if (!localStorage.getItem('lang')) {
  localStorage.setItem('lang', 'zh');
}
if (!localStorage.getItem('themeMode')) {
  localStorage.setItem('themeMode', 'light');
}
i18n.changeLanguage(localStorage.getItem('lang'));

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
